import React, { useEffect, useState } from 'react'
import { withRouter } from 'react-router-dom'
import items from './Item.module.css'
import { UserOutlined, LikeFilled, EditFilled, BranchesOutlined } from '@ant-design/icons';
import { Avatar } from 'antd';
// const obj = {
//   title: '球鞋 yeezy 2002 nb款',
//   price: '2400',
//   salecount: 20002,
//   img: [{}],
//   info: `沟通与黄帝纪年法定货阿萨大撒旦币供应的阿萨大大太a阿三大苏打阿三大苏打阿三大苏打阳和方法
//   好多年不给发红包好友和佛教年度报告不阿三大苏打a's以后你就订单`,
//   likenum: 10,
//   username: 'sdsdsd'
// }
class Card extends React.Component {
  constructor(props){
    super(props)
  }
  liked = ()=>{
    console.log(1)
  }
  render(){
    let obj = {...this.props,img:[{}]}
  return <div className={items.container}>
    <div className={items.header}>
      <Avatar size={30} icon={<UserOutlined />} style={{ marginLeft: '.1rem' }} />
      <div className={items.headerInfo}>
        <div className={items.title}>{obj.pname || obj.username}</div>
        <div className={items.priceInfo}>
          <span className={items.price}>￥{obj.price || 1234}</span>
          <span className={items.salecount}>{obj.salecount}人付款</span>
        </div>
      </div>
    </div>
    <div className={items.info} onClick={()=>this.props.history.push('/Dydetail',{mid:obj.mid,uid:obj.uid})}>
      <div>{obj.mtext}</div>
      <div className={items.imgBox}>
        {
          obj.img.map(el => <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww2.flightclub.cn%2Fnews%2Fuploads%2Fallimg%2F191216%2F14-191216103110.jpg&refer=http%3A%2F%2Fwww2.flightclub.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1620368135&t=c28a0ccd0b6d8280c90f9d1c700bea87" className={items.img} />)
        }
      </div>
    </div>
    <div className={items.footer}>
      <div style={{ display: 'flex', alignItems: 'center' }}>
        <Avatar size={20} icon={<UserOutlined />} style={{ margin: '.1rem' }} />
        <span>{obj.username}</span>
      </div>
      <div style={{ display: 'flex', alignItems: 'center' }}>
        <EditFilled size={20} style={{ marginRight: '.4rem' }} />
        <div style={{ marginRight: '.3rem' }}>
          <LikeFilled size={20}  onClick={()=>this.liked}/>{obj.likenumber}
        </div>
        <div style={{ marginRight: '.2rem' }}>
          <BranchesOutlined size={20}  />{obj.scancount}
        </div>
      </div>
    </div>
  </div>
  }
}
export default withRouter(Card)